const worker=new Worker("./worker.js")

const channel=new BroadcastChannel("timer_channel");

channel.onmessage=function(event){
    console.log("收到wroker的消息：",event.data);
    let {msg,data}=event.data;
    msg?msg=msg:msg="请点击开始计时";
    data?data=data:data=0;
    document.getElementById("message").textContent=msg+":"+data;
}

function startTimer(){
    channel.postMessage("start")
}

function stopTimer(){
    channel.postMessage("stop")
}